/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.solrtools.service;

import br.com.solrtools.dao.DAOSolrFactory;
import br.com.solrtools.solrquerydao.SolrQueryDao;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.ModifiableSolrParams;

/**
 *
 * @author eleazer
 */
public class QueryServiceImpl implements QueryService {

    private static final Logger LOGGER = Logger.getLogger(QueryServiceImpl.class.getName());
	
    private static DAOSolrFactory daoFactory = DAOSolrFactory.getInstance();
    private SolrQueryDao solrServer;
        
    @Override
    public List<String> searchAll() throws Exception {
        Collection<String> docListName;
        List<String> documentList = new ArrayList<String>();
        try{
            solrServer = daoFactory.getSolrDAO();
            SolrDocumentList documents = solrServer.findAllDocuments();
                    
            for(SolrDocument document : documents) {
                    docListName = document.getFieldNames();
                    for(String name : docListName) {
                        documentList.add(name + "-");
                    }
            }   
        }catch(ExceptionInInitializerError e){
            LOGGER.log(Level.INFO, "Metodo searchAll da classe QueryServiceImpl: {0}", e);
        }
	return documentList;
    }

    
}
